/**O_DIRECT
sudo tune2fs -l /dev/sda1 | grep "Block size"
 */
#define _GNU_SOURCE
#include<errno.h>
#include<stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>

static char buf[4096] __attribute((aligned(4096)));
int main(void){
	int fd,ret;
	fd=open("./test.txt",O_WRONLY | O_CREAT | O_EXCL | O_DIRECT,0666);
	if(-1==fd){
		perror("open error");
		return 1;
	}
	lseek(fd,0,SEEK_SET);
	for(int i=0;i<4096;i++){
		ret=write(fd,buf,sizeof(buf));
		if(-1==ret){
			perror("write error\n");
			close(fd);
			return 1;
		}
	}
	close(fd);
	return 0;

}
